package com.hanfengyi.user.web.controller;

import com.hanfengyi.hrm.AjaxResult;
import com.hanfengyi.user.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * User: Han
 * Date: 2020/3/2
 * Time: 17:20
 * Description:
 */
@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {
    @Autowired
    private IVerifyCodeService verifyCodeService;

    @PostMapping("/imageCode/{imageCodeKey}")
    public String imageCodeGenerate(@PathVariable("imageCodeKey")String imageCodeKey){

        return verifyCodeService.imageCodeGenerate(imageCodeKey);
    }

    @PostMapping("/sendSmsCode")
    public AjaxResult sendSmsCode(@RequestBody Map<String,String> map){
        try {
            verifyCodeService.sendSmsCode(map);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage(e.getMessage());
        }
    }
}